package com.weitu.contractor.service.impl;

import com.weitu.contractor.entity.ManagerCert;
import com.weitu.contractor.entity.ManagerCertCriteria;
import com.weitu.contractor.mapper.ManagerCertMapper;
import com.weitu.contractor.service.ManagerCertService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ManagerCertServiceImpl implements ManagerCertService {
    private final ManagerCertMapper managerCertMapper;

    private static final Logger logger = LoggerFactory.getLogger(ManagerCertServiceImpl.class);

    @Autowired
    public ManagerCertServiceImpl(ManagerCertMapper managerCertMapper) {
        this.managerCertMapper = managerCertMapper;
    }

    @Override
    public int countByCriteria(ManagerCertCriteria example) {
        int count = this.managerCertMapper.countByCriteria(example);
        logger.debug("count: {}", count);
        return count;
    }

    @Override
    public ManagerCert selectByPrimaryKey(String id) {
        return this.managerCertMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ManagerCert> selectByCriteria(ManagerCertCriteria example) {
        return this.managerCertMapper.selectByCriteria(example);
    }

    @Override
    @Transactional
    public int deleteByPrimaryKey(String id) {
        return this.managerCertMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public int updateByPrimaryKeySelective(ManagerCert record) {
        return this.managerCertMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    @Transactional
    public int updateByCriteriaSelective(ManagerCert record, ManagerCertCriteria example) {
        return this.managerCertMapper.updateByCriteriaSelective(record, example);
    }

    @Override
    @Transactional
    public int insertSelective(ManagerCert record) {
        return this.managerCertMapper.insertSelective(record);
    }

    @Override
    public List<ManagerCert> selectByPersonId(String personId) {
        ManagerCertCriteria criteria = new ManagerCertCriteria();
        criteria.createCriteria()
                .andDelStateEqualTo(0)
                .andPersonIdEqualTo(personId);
        return managerCertMapper.selectByCriteria(criteria);
    }
}